//  

#region

using System;
using System.Windows;
using Microsoft.Practices.Composite.Logging;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Unity;
using pushbomb.composite.core;
using pushbomb.composite.core.Infrastructure;

#endregion

namespace HitTester.Observable
{
    public class Bootstrapper : CompositeUnityBootstrapper
    {
        private static readonly ObservableLogger _logger = new ObservableLogger();

        protected override ILoggerFacade LoggerFacade
        {
            get
            {
                
               
                return _logger;
            }
        }

        protected override DependencyObject CreateShell()
        {
            var resolve = Container.Resolve<IViewModel>("shellVM");

            return Application.Current.RootVisual = resolve.View;
        }

        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();

            Container.RegisterType<IFrameworkServiceProvider, FrameworkServiceProvider>(
                new ContainerControlledLifetimeManager());

            Container.RegisterType<ILogPublisher, LogPublisher>(new ContainerControlledLifetimeManager());
                                        
            Container.RegisterType<IView, MainPage>("Shell");
            Container.RegisterType<IViewModel, ShellViewModel>("shellVM", new ContainerControlledLifetimeManager());

        }

        protected override IModuleCatalog GetModuleCatalog()
        {
            return
                ModuleCatalog.CreateFromXaml(new Uri("/HitTester.Observable;Component/ModulesCatalog.xaml",
                                                     UriKind.Relative));
        }
    }
}